{include file='fcworker/fc_userdata_head'}
		<style>
			.focuseSearchbox .layui-form {
				float: left;
				width: 2.3rem;
				height: .8rem;
			}
			.focuseSearchbox .layui-inline {
				height: 100%;
			}
			.focuseSearchbox .layui-form-select {
				height: 100%;
			}
			.focuseSearchbox .layui-select-title {
				height: 100%;
			}

			.focuseSearchbox .layui-form-select .layui-input {
				background: transparent;
				height: 100%;
				/*padding-bottom: .08rem;*/
			}
			.focuseSearchbox .layui-form .layui-form-select dl dd.layui-this {
				background-color: #70b6f7;
			}
		</style>
<div id="mescroll" class="mescroll">
	<div id="app">
		<div style="position: sticky; top: 0;background-color: #fff; z-index: 1">
			<div class="journalTitle">
				<a href="/{php echo createMobileUrl('main',array('themeid'=>$themeid,'mod'=> 'userdata','op' => 'log_list'));}" >日志</a>
				<a class="cur" href="/{php echo createMobileUrl('main',array('themeid'=>$themeid,'mod'=> 'userdata','op' => 'focuse_list'));}">关注</a>
				<a href="/{php echo createMobileUrl('main',array('themeid'=>$themeid,'mod'=> 'userdata','op' => 'trace_list'));}">追踪</a>
			</div>
			<div class="focuseSearch">
				<div class="focuseSearchbox">
					<span>条件：</span>
					<div class="layui-form">
						<div class="layui-inline">
							<select name="condition_type2" lay-verify="" id="condition_type2">
								{loop  $types_data  $val}
								{if $val['type']>0}
								<option value ="{$val['type']}" {if $type==$val['type']} selected {/if}>{$val['name']}</option>
								{/if}
								{/loop}
							</select>
						</div>
					</div>
					<span style="margin-left: .15rem;">大于</span>
					<input type="text" id="type_num" name="type_num" value="{$type_num}" style="margin-top: .1rem;height: .55rem; line-height: .55rem;"/>
					<span>次</span>
					<button type="button" id="search_btn">搜索</button>
				</div>

				<div class="searchType">
					{loop $quick_input  $row}
					<a href="{php echo "/".createMobileUrl('main',array("themeid"=>$themeid,"mod"=> "userdata","op"=>$op,"type"=>$row['type'],"type_num" =>$row['num']));}">{$row['name']} <i>{$row['count']}</i></a>
					{/loop}
				</div>
			</div>
		</div>
		<div class="journalList">
			<ul id="newsList"  class="news-list">

			</ul>
		</div>
		<input type="hidden" name="type" id="type" value="{$type}">
		<input type="hidden" name="page" id="page" value="1">
		<input type="hidden" name="op" id="op" value="focuse_list">
		<input type="hidden" name="hasNext" id="hasNext" value="{$hasNext}">
		<div style="height: 1.1rem;"></div>
	</div>
</div>
</body>

<script type="text/javascript" charset="utf-8">
	const mescroll = new MeScroll("mescroll", {
		down: {
			auto: false,
			callback: () => {
				mescroll.endSuccess();
				getData(1,() => {
					mescroll.endSuccess()
				},true)
			}
		},
		up: {
			use: true,
			auto: false,
			isBounce: false,
			callback: (page) => {
				let pageNum = Number($("#page").val())+1;
				getData(pageNum, (curPageData, hasNext) => {
					mescroll.endSuccess(curPageData, hasNext);
				});
			}
		}
	})
	// if(!$("#hasNext").val()) {
	// 	mescroll.lockUpScroll(true);
	// }
	var loadingState= false;
	var hasNext = 1;
	$('#search_btn').click(function(){
		sessionStorage.removeItem('focuse_page_list');
		sessionStorage.removeItem('focuse_offset_top');
		var type = $('#type').val()
		var type_num = $('#type_num').val();
		location.href = "/{php echo createMobileUrl('main',array('themeid'=>$themeid,'mod'=> 'userdata','op' => $op));}&type="+type+"&type_num="+type_num;
	})

	$('#newsList').on('click','.controlBar > i',function(event){
		$(".controlList").hide();
		event.stopPropagation();
		if ($(this).prev().is(':hidden')) {
			$(this).prev().show();
		}else{
			$(this).prev().hide();
		}
	});

	$('#mescroll').scroll(function() {
		const scrollSpace = $(this).scrollTop()
		sessionStorage.setItem("focuse_offset_top",scrollSpace);//保存滚动位置
	})

	window.onload = function()
	{
		var pageList = sessionStorage.getItem("focuse_page_list");
		if(pageList!=null){
			$("#newsList").html(pageList);
			var hasNext = sessionStorage.getItem("focuse_has_next");
			$("#hasNext").val(hasNext);
			var offset = sessionStorage.getItem("focuse_offset_top");
			$('#mescroll').scrollTop(offset);
			$("#page").val(sessionStorage.getItem("focuse_page_index"));
			if(sessionStorage.getItem("focuse_type")!=null){
				$('#condition_type2').val(sessionStorage.getItem("focuse_type"));
			}
			if(sessionStorage.getItem("type_num")){
				$('#type_num').val(sessionStorage.getItem("type_num"));
			}
			//sessionStorage.removeItem('focuse_page_list');
			//sessionStorage.removeItem('focuse_offset_top');
		}else{
			var page = $("#page").val();
			getData(page);
		}
	};


	// $(window).scroll(function(){
	// 	hasNext = $("#hasNext").val();
	// 	var height = $(window).height();
	// 	var scrollSpace = $(window).scrollTop();
	// 	if(scrollSpace>height){
	// 		$('.backTop').fadeIn();
	// 	}else{
	// 		$('.backTop').fadeOut();
	// 	}
	// 	if (scrollSpace >= $(document).height() -  (height*1.2)){
	// 		if (!loadingState && hasNext==1){
	// 			loadingState = true;
	// 			layer.msg('加载中', {
	// 				icon: 16
	// 				,shade: 0.01
	// 			});
	// 			var page = $("#page").val();
	// 			var next_page = +page+1;
	// 			getData(next_page)
	// 		}
	// 	}
	// })

	function  getData(page, cb,isRefresh = false){
		$("#page").val(page);
		var type = $('#type').val();
		var type_num = $('#type_num').val();
		var op = $("#op").val();
		var postUrl="/{php echo  createMobileUrl('main',array('themeid'=>$themeid,'mod'=> 'userdata'));}";
		$.ajax({
			url:postUrl,
			dataType:'json',
			method:'post',
			data: {op:op,page:page,type:type,type_num:type_num},
			success:function (e) {
				let data = e.data.res_list;
				let error = e.error;
				let msg = e.msg;
				if (error!=0){
					layer.msg(msg);
				}else{
					var curPageData = data.curPageData;
					var hasNext = data.hasNext;
					setListData(curPageData, !isRefresh);
					layer.closeAll();
					if(cb && typeof cb === 'function') {
						cb(curPageData.length, hasNext);
					}
				}
				loadingState = false;
				if (data.hasNext){
					hasNext = 1;
				}else{
					hasNext = 0;
				}
				$("#hasNext").val(hasNext);
				 // $("#page").val(next_page);
				sessionStorage.setItem('focuse_page_index',page);
				sessionStorage.setItem('focuse_loading_state',loadingState);
				sessionStorage.setItem('focuse_has_next',hasNext);
				setTimeout(() => {
					sessionStorage.setItem('focuse_page_list', $('#newsList').html());
				},200);

				if(type>0){
					sessionStorage.setItem('focuse_type',type);
				}else{
					sessionStorage.removeItem('focuse_type')
				}

				if(type_num>0){
					sessionStorage.setItem('focuse_type_num',type_num);
				}else{
					sessionStorage.removeItem('focuse_type_num')
				}

			},
			fail:function (err) {
				console.log(err)
			}
		});
	}


	layui.use('form', function(){
		const form = layui.form;
		var type_num = $('#type_num').val();
		setTimeout(() => {
			$('select[name=condition_type2]').val({php echo $type ? $type : 1;})
		})
		form.on('select', function (data) {
			sessionStorage.removeItem('focuse_page_list');
			sessionStorage.removeItem('focuse_offset_top');
			location.href = `/{php echo createMobileUrl('main',array('themeid'=>$themeid,'mod'=> 'userdata','op' => $op));}&type=${data.value}&type_num=${type_num}`;
		})
		// form.render('select');
		form.render();
	});

</script>
{include file='fcworker/fc_userdata_setList'}

{if $system['h5work'] == '1'}
{include file='fcworker/fc_foot'}
{else}
{include file='yxworker/w_foot'}
{/if}

